class Solution
{
public:
    ListNode* mergeInBetween(ListNode* list1, int a, int b, ListNode* list2)
    {
        ListNode* strat = list1;
        for (int i = 0; i < a - 1; i++)
        {
            strat = strat->next;
        }
        ListNode* end = strat;
        for (int i = 0; i < b - a + 2; i++)
        {
            end = end->next;
        }
        strat->next = list2;
        while (list2->next != nullptr)
        {
            list2 = list2->next;
        }
        list2->next = end;
        return list1;
    }
};